package io.netty.test.main.google;

import com.google.protobuf.InvalidProtocolBufferException;
import org.ly817.test.google.proto.DataInfo;

/**
 * Created by LuoYu on 2019/2/18.
 */
public class ProtoBootstrap {
    public static void main(String[] args) throws InvalidProtocolBufferException {
        // 构造对象
        DataInfo.Student student = DataInfo.Student.newBuilder()
                                            .setName("luoyu")
                                            .setAge(20)
                                            .setAddress("earth").build();
        // 序列化
        byte[] student2Byte = student.toByteArray();


        // 反序列化
        DataInfo.Student student1 = DataInfo.Student.parseFrom(student2Byte);
        System.out.println(student1);
    }
}
